<template>
	<div id="auction">
		<div class="banner">
			<img src="../../static/img/auction-04.png"/>
		</div>
		<div id="content">
			<div class="choice">
				<div id="title_2" class="good_title">
					<div class="title_l">
		  				<p><img src="../../static/img/auction-01.png"/>赶紧拍</p>
		  				<!--<p>每天22:00公布竞拍结果</p>-->
		  			</div>
	  				<div class="title_r">
	  					<p style="font-weight: normal;"><span style="font-weight: 600;margin-right: 5px;color: #FF464E;">1205482</span>次围观</p>
	  				</div>
				</div>
				<div class="position">
					<p>当前位置：首页 &gt; 赶紧拍</p>
					<div class="good_search">
						<input type="text" placeholder="宝贝名称关键词" ref="taskName"/>
						<img src="../../static/img/good-02.png" @click="search2"/>
					</div>
				</div>
				<!---------筛选-------------->
				<div class="classify">
					<div class="classify_item">
						<p>商品类目：</p>
						<ul>
							<li @click="classify2('')" :class="classify2_num == ''?'classify_active':''">全部</li>
							<li @click="classify2('女装')" :class="classify2_num == '女装'?'classify_active':''">女装</li>
							<li @click="classify2('男装')" :class="classify2_num == '男装'?'classify_active':''">男装</li>
							<li @click="classify2('鞋包')" :class="classify2_num == '鞋包'?'classify_active':''">鞋包</li>
							<li @click="classify2('百货')" :class="classify2_num == '百货'?'classify_active':''">百货</li>
							<li @click="classify2('母婴')" :class="classify2_num == '母婴'?'classify_active':''">母婴</li>
							<li @click="classify2('配饰')" :class="classify2_num == '配饰'?'classify_active':''">配饰</li>
							<li @click="classify2('电器')" :class="classify2_num == '电器'?'classify_active':''">电器</li>
							<li @click="classify2('家居')" :class="classify2_num == '家居'?'classify_active':''">家居</li>
							<li @click="classify2('美妆')" :class="classify2_num == '美妆'?'classify_active':''">美妆</li>
							<li @click="classify2('食品')" :class="classify2_num == '食品'?'classify_active':''">食品</li>
							<li @click="classify2('车品')" :class="classify2_num == '车品'?'classify_active':''">车品</li>
						</ul>
					</div>
				</div>
				<!-------------排序-------------->
				<div class="sort">
					<p>商品排序：</p>
					<ul>
						<li @click="sort(0)" :class="sort_num == 0?'sort_active':''">
							<p>综合</p>
							<!--<img src="../../static/img/good-03.png"/>-->
						</li>
						<li @click="sort(1)" :class="sort_num == 1 || sort_num == 2?'sort_active':''">
							<p>最新</p>
							<img :class="sort_num == 1?'rot':''" src="../../static/img/good-03.png"/>
						</li>
						<li @click="sort(3)" :class="sort_num == 3 || sort_num == 4?'sort_active':''">
							<p>价值</p>
							<img :class="sort_num == 3?'rot':''" src="../../static/img/good-03.png"/>
						</li>
						<li @click="sort(5)" :class="sort_num == 5 || sort_num == 6?'sort_active':''">
							<p>人气</p>
							<img :class="sort_num == 5?'rot':''" src="../../static/img/good-03.png"/>
						</li>
					</ul>
					<div class="money">
						<p>价值筛选</p>
						<div class="money_input">
							<span>¥</span>
							<input type="number" ref="minPrice"/>
						</div>
						<span>-</span>
						<div class="money_input">
							<span>¥</span>
							<input type="number" ref="maxPrice"/>
						</div>
						<input type="button" value="确定" @click="search"/>
					</div>
				</div>
				<!------------任务列表--------------->
				<div class="choice_list">  
					<div @click="applyTask(item.task.id)" v-for="item in taskList" class="task_item">
						<div class="task_img">
							<div class="shade"></div>
			  				<div class="goods_img">
			  					<img src="../../static/img/imgLoading.png"/>
			  					<div class="img_box">
			  						<img :src="item.task.goodsImage"/>
			  					</div>
			  				</div>
						</div>
		  				<div class="task_title">
		  					<img :src="getPaltformImg(item.task.paltform)"/>
		  					<p>{{item.task.taskName}}</p>
		  				</div>
						<div class="price">
							<p>当前价<span>¥{{item.taskList.currMaxPrice}}</span></p>
							<p>({{item.task.applyNum}}次出价)</p>
						</div>
						<p>商品价值 ￥{{item.task.price}}</p>
						<p>距结束{{getTimeN(item.taskList.openingTime)}}</p>
						<img src="../../static/img/auction-02.png"/>
		  			</div>
				</div>
				<!----------分页--------------->
				<el-pagination
				background
			    @current-change="handleCurrentChange"
			    :current-page.sync="currentPage"
			    :page-size="pageSize"
			    :pager-count="5"
			    layout="prev, pager, next, jumper"
			    :total="total">
				</el-pagination>
			</div>
			<!---------------近期预告------------------->
			<div class="trailer">
				<div id="title_2" class="good_title">
					<div class="title_l">
		  				<p><span>近期</span>预告</p>
		  				<!--<p>每天22:00公布竞拍结果</p>-->
		  			</div>
	  				<div class="title_r">
	  					<p>明天开始</p>
	  				</div>
				</div>
				<!------------任务列表--------------->
				<div class="choice_list">  
					<div @click="applyTask(item.id)" v-for="item in taskList2.slice(0,10)" class="task_item">
						<div class="task_img">
							<div class="shade"></div>
			  				<div class="goods_img">
			  					<img src="../../static/img/imgLoading.png"/>
			  					<div class="img_box">
			  						<img :src="item.task.goodsImage"/>
			  					</div>
			  				</div>
						</div>
		  				<div class="task_title">
		  					<img :src="getPaltformImg(item.task.paltform)"/>
		  					<p>{{item.task.taskName}}</p>
		  				</div>
						<div class="price">
							<p>当前价<span>¥{{item.taskList.currMaxPrice}}</span></p>
						</div>
						<p>商品价值 {{item.task.price}}</p>
						<p>距结束24时00分</p>
						<img src="../../static/img/auction-03.png"/>
		  			</div>
				</div>
			</div>
				
		</div>
	</div>
</template>

<script>
export default {
	name: 'auction',
	data:function(){
		return{
			oneDay:'',
			task_time:'',
			taskName:'',
			minPrice:null,
			maxPrice:null,
			recommend_num:1,
			classify1_num:0,//活动类型
			classify2_num:'',//分类
			sort_num:5,//排序
			total: 0,//总条数
			pageSize: 30,//每页条数
			currentPage: 1,//当前页码
			taskList:[],
		    taskList2:[],
		}
	},
	methods:{
		classify2:function(n){
			this.classify2_num = n;
			this.currentPage = 1;
			this.showCondition();
			this.countCondition();
		},
		sort:function(n){
			if(this.sort_num==n&&n!=0){
				this.sort_num += 1;
			}else{
				this.sort_num = n;
			}
			this.currentPage = 1;
			this.showCondition();
		},
		search:function(){
			this.minPrice = this.$refs.minPrice.value;
			this.maxPrice = this.$refs.maxPrice.value;
			this.currentPage = 1;
			this.showCondition();
			this.countCondition();
		},
		search2:function(){
			this.taskName = this.$refs.taskName.value;
			this.currentPage = 1;
			this.showCondition();
			this.countCondition();
		},
		showGoods:function(){
			var _this = this;
			let postData = _this.$qs.stringify({
				orderBy:5,
				startPage:1,
				pageSize:10,
				istom:1
	        })
			_this.$axios.post('/agent/home/public/auctionCondition',postData).then(function(res){
			    var data = res.data;
			    if(data.message=="succ"){
			    	data = data.result;
			    	_this.taskList2 = data;
			    	console.log(data);
			    }else{
			    	_this.$alert("2",data.result);
			    }
//		    	_this.taskList = data;
			}).catch(function (error) {
			    console.log(error);
			});
		},
		showCondition:function(){
			var _this = this;
			let postData = _this.$qs.stringify({
				orderBy:_this.sort_num,
				startPage:_this.currentPage,
				pageSize:_this.pageSize,
				goodsType:_this.classify2_num,
				minPrice:_this.minPrice,
				maxPrice:_this.maxPrice,
				taskName:_this.taskName,
	        })
			_this.$axios.post('/agent/home/public/auctionCondition',postData).then(function(res){
			    var data = res.data;
			    if(data.message=="succ"){
			    	data = data.result;
			    	_this.taskList = data;
			    	console.log(data);
			    }else{
			    	_this.$alert("2",data.result);
			    }
//		    	_this.taskList = data;
			}).catch(function (error) {
			    console.log(error);
			});
		},
		countCondition:function(){
			var _this = this;
			let postData = _this.$qs.stringify({
				orderBy:_this.sort_num,
				goodsType:_this.classify2_num,
				minPrice:_this.minPrice,
				maxPrice:_this.maxPrice,
				taskName:_this.taskName,
	        })
			_this.$axios.post('/agent/home/public/countCondition',postData).then(function(res){
			    var data = res.data;
			    if(data.message=="succ"){
			    	data = data.result;
			    	_this.total = data;
			    	console.log(data);
			    }else{
			    	_this.$alert("2",data.result);
			    }
			}).catch(function (error) {
			    console.log(error);
			});
		},
		//-----------分页页码改变------------
	    handleCurrentChange:function(val) {
	        this.currentPage=val;
	        this.showCondition();
	    },
	    //--------平台图标判断------------
	    getPaltformImg:function(obj){
			if(obj==1){
				return "./../static/img/tb.png";
			}else if(obj==2){
				return "./../static/img/tm.png";
			}else if(obj==3){
				return "./../static/img/jd.png";
			}
		},
		//--------前往任务详情页-----------
		applyTask:function(obj){
			this.$router.push({path:'/home/detailAuction?taskId='+obj})
		},
		getTimeN:function(obj){
			var date = new Date();
			var time = obj - date.getTime();
			var h = parseInt(time/1000/60/60%24);
			var m = parseInt(time/1000/60%60);
			return h+"小时"+m+"分";
		},
	},
	created:function(){
//		$.post('/api/wallet/show', function(res){
//		   console.log(res) 
//		})
		var Id = this.$route.query.id;
		if(!Id){
			Id = '';
		}
		if(this.$route.query.taskName){
			this.taskName = this.$route.query.taskName
		}
		this.classify2_num = Id;
		this.showGoods();
		this.showCondition();
		this.countCondition();
	},
	watch:{
		$route(){
			this.taskName = this.$route.query.taskName;
			this.showCondition();
			this.countCondition();
		}
	}
}
</script>

<style>
/*-----------分页器样式------------*/
#auction .el-pagination{
	text-align: center !important;
	margin-top: 20px !important;
	margin-bottom: 20px !important;
}
#auction .el-pagination.is-background .el-pager li:not(.disabled).active{
	background-color: #FF464E !important;
}
#auction .el-pagination.is-background .el-pager li:not(.active):hover{
	color: #FF464E !important;
}
</style>

<style scoped>
.banner{
	width: 1230px;
	margin: 0 auto;
	margin-top: 20px;
}
.banner img{
	width: 100%;
	display: block;
}
#content{
	width: 1230px;
	margin: 0 auto;
}
/*----标题----------*/
.good_title{
	display: flex;
	justify-content: space-between;
	align-items: flex-end;
	margin-top: 20px;
	margin-bottom: 10px;
}
#title_2{
	border-bottom: 2px solid #ff9a9e;
	padding-bottom: 8px;
}
.title_l{
	display: flex;
	align-items: flex-end;
}
.title_l p:first-child{
	display: flex;
	align-items: center;
	font-size: 16px;
	font-weight: bold;
}
.title_l p:first-child span{
	width: 3px;
	height: 14px;
	background-color: #4D4D4D;
	margin-right: 5px;
}
.title_l p:first-child img{
	height: 20px;
	display: block;
	margin-right: 5px;
}
.title_l p:last-child{
	color: #9F9F9F;
	height: 17px;
	margin-left: 10px;
}
.title_r{
	display: flex;
}
.title_r li{
	width: 12px;
	height: 12px;
	border-radius: 50%;
	background-color: #DDDDDD;
	margin-left: 10px;
	cursor: pointer;
}
.title_r li.recommend_active{
	background-color: #FF464E;
}
.title_r p{
	font-weight: bold;
	color: #FF464E;
	font-size: 16px;
}
.title_r p span{
	color: #4D4D4D;
}
/*----------单个任务-------------*/
.task_item{
	width: 238px;
	background-color: #fff;
	padding: 20px;
	box-sizing: border-box;
	margin-right: 10px;
	margin-bottom: 10px;
	border: 1px solid transparent;
	cursor: pointer;
	position: relative;
}
.task_item:hover{
	border: 1px solid #FF464E;
}
.task_item:hover .shade{
	display: block;
}
.task_img{
	position: relative;
}
.task_img .shade{
	width: 100%;
	height: 100%;
	position: absolute;
	top: 0;
	left: 0;
	background-color: rgba(255,255,255,0.2);
	display: none;
}
.task_img img{
	width: 100%;
	display: block;
}
.goods_img{
	position: relative;
	width: 100%;
}
.goods_img>img{
	width: 100%;
	display: block;
}
.goods_img .img_box{
	position: absolute;
	width: 100%;
	height: 100%;
	top: 0;
	left: 0;
	overflow: hidden;
	display: flex;
	align-items: center;
}
.goods_img .img_box img{
	width: 100%;
	display: block;
}
.task_title{
	margin-top: 5px;
	display: flex;
	align-items: flex-end;
}
.task_title img{
	display: block;
	height: 20px;
	margin-right: 5px;
}
.task_title p{
	width: calc(100% - 25px);
	height: 20px;
	line-height: 28px;
	color: #5E5E5E;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}
.price{
	margin-top: 8px;
}
.price p:first-child{
	display: inline-block;
	color: #5E5E5E;
}
.price p:first-child span{
	font-size: 18px;
	color: #FF464E;
	margin: 0 5px;
}
.price p:last-child{
	color: #9F9F9F;
	display: inline-block;
}
.task_item>p{
	color: #5E5E5E;
	margin-top: 10px;
}
.task_item>img{
	height: 24px;
	display: block;
	position: absolute;
	bottom: 20px;
	right: -5px;
}
/*---------精选好货-----------*/
.position{
	display: flex;
	align-items: center;
	font-size: 16px;
	color: #4D4D4D;
	margin-bottom: 10px;
}
.good_search{
	background-color: #fff;
	border: 1px solid #DDDDDD;
	width: 250px;
	height: 35px;
	display: flex;
	align-items: center;
	padding: 0 10px;
	margin-left: 20px;
}
.good_search input{
	width: calc(100% - 20px);
	height: 100%;
	border: none;
	font-size: 14px;
}
.good_search img{
	height: 20px;
	display: block;
}
/*-------筛选-------------*/
.classify{
	border: 1px solid #DDDDDD;
	box-sizing: border-box;
	background-color: #fff;
}
.classify_item{
	display: flex;
	align-items: center;
	color: #5E5E5E;
	padding: 14px 10px;
}
.classify_item ul{
	display: flex;
	align-items: center;
}
.classify_item ul li{
	margin-left: 30px;
	cursor: pointer;
}
.classify_item ul li.classify_active{
	color: #FF464E;
}
/*------排序---------*/
.sort{
	background-color: #fff;
	padding: 10px;
	display: flex;
	align-items: center;
	border: 1px solid #DDDDDD;
	border-top: none;
}
.sort ul{
	display: flex;
}
.sort ul li{
	display: flex;
	align-items: center;
	margin-left: 30px;
	cursor: pointer;
}
.sort ul li img{
	height: 15px;
	display: block;
	margin-left: 3px;
	opacity: 0;
}
li.sort_active{
	color: #FF464E;
}
.sort ul li.sort_active img{
	opacity: 1;
}
img.rot{
	transform: rotateZ(180deg);
}
.money{
	display: flex;
	align-items: center;
	margin-left: 100px;
}
.money p{
	margin-right: 10px;
}
.money_input{
	border: 1px solid #DDDDDD;
	display: flex;
	align-items: center;
	height: 25px;
	width: 100px;
	padding-left: 5px;
	box-sizing: border-box;
	color: #9F9F9F;
}
.money_input input{
	border: none;
	width: calc(100% - 15px);
	height: 100%;
	padding-left: 5px;
	box-sizing: border-box;
}
.money>span{
	margin: 0 5px;
	color: #9F9F9F;
}
.money input[type='button']{
	border: none;
	background-color: #FF464E;
	color: #FFFFFF;
	width: 60px;
	height: 25px;
	margin-left: 10px;
}
/*-----------任务列表--------------*/
.choice_list{
	display: flex;
	flex-wrap: wrap;
	margin-top: 20px;
}
.choice_list .task_item:nth-child(5n){
	margin-right: 0;
}
/*------------分页-----------*/
.paging{
	display: flex;
	align-items: center;
	justify-content: center;
	margin-top: 10px;
	margin-bottom: 30px;
}
.last,.next,.paging_list li{
	width: 30px;
	height: 30px;
	border: 1px solid #E6E6E6;
	display: flex;
	align-items: center;
	justify-content: center;
	color: #9F9F9F;
	box-sizing: border-box;
	cursor: pointer;
}
.last img,.next img{
	height: 18px;
	display: block;
}
.next,.paging_list li{
	margin-left: 8px;
}
.paging_list{
	display: flex;
}
.topaging{
	display: flex;
	align-items: center;
	margin-left: 8px;
}
.topaging p{
	color: #9F9F9F;
}
.topaging input[type='text']{
	width: 30px;
	height: 30px;
	text-align: center;
	border: 1px solid #E6E6E6;
	margin: 0 5px;
	background-color: transparent;
	color: #5E5E5E;
}
.topaging input[type='button']{
	height: 30px;
	width: 60px;
	border: 1px solid #E6E6E6;
	background-color: transparent;
	margin-left: 8px;
	color: #5E5E5E;
}
span.paging_active,li.paging_active{
	background-color: #FF464E;
	color: #FFFFFF;
	border: none;
}	
/*--------------近期预告----------------*/
.trailer #title_2{
	border-bottom: 2px solid #46C780;
}
.trailer .title_l p span{
	height: auto;
	margin-right: 0;
	width: auto;
	color: #46C780;
	background: transparent;
}
.trailer .title_r p{
	color: #46C780;
}
.trailer .task_item:hover{
	border: 1px solid #46C780;
}
.trailer .price p{
	color: #5E5E5E;
}
.trailer .price p span{
	color: #46C780;
}
</style>
